/*
 * @Author: qin
 * @Date:   2018-08-28
 * +----------------------------------------------------------------------
 * | admin [ 后台管理系统公共配置信息 ]
 * | 表单序列化转对象封装
 * +----------------------------------------------------------------------
 */
layui.define(['jquery'], function (exports) {
    var $ = layui.jquery;
    var serializeObject = {
        init: function (arr) {
            var jsonObj = {};
            $.each(arr, function () {
                if (jsonObj[this.name]) {
                    if (jsonObj[this.name].push) {
                        jsonObj[this.name] = [jsonObj[this.name]];
                    }
                    jsonObj[this.name].push(this.value || '');
                } else {
                    jsonObj[this.name] = this.value || '';
                }
            });
            return jsonObj;
        }
    };

    exports('serializeObject', serializeObject);
});